package com.spring.security.web.model;

import com.fasterxml.jackson.annotation.JsonFormat;

import java.io.Serializable;
import java.util.Date;

import org.springframework.format.annotation.DateTimeFormat;

/**
 * Created by WoJunyu on 2016/9/7.
 */
public class BaseModel implements Serializable{

    /**
     *
     */
    private static final long serialVersionUID = 1L;

    private Date createdtime;

    private Date changedtime;
    
    @DateTimeFormat(pattern="yyyy-MM-dd")  
    private Date createdtimeYMD;
    
    @DateTimeFormat(pattern="yyyy-MM-dd")  
    private Date changedtimeYMD;

    private String initialoperatorid;

    private String initialoperatorname;

    private String operatorid;

    private String operatorname;

    private Integer entityavailablestate;

    public Date getCreatedtime() {
        return createdtime;
    }

    public void setCreatedtime(Date createdtime) {
        this.createdtime = createdtime;
        setCreatedtimeYMD(createdtime);
    }

    public Date getChangedtime() {
        return changedtime;
    }

    public void setChangedtime(Date changedtime) {
        this.changedtime = changedtime;
        setChangedtimeYMD(changedtime);
    }

    public String getInitialoperatorid() {
        return initialoperatorid;
    }

    public void setInitialoperatorid(String initialoperatorid) {
        this.initialoperatorid = initialoperatorid == null ? null : initialoperatorid.trim();
    }

    public String getInitialoperatorname() {
        return initialoperatorname;
    }

    public void setInitialoperatorname(String initialoperatorname) {
        this.initialoperatorname = initialoperatorname == null ? null : initialoperatorname.trim();
    }

    public String getOperatorid() {
        return operatorid;
    }

    public void setOperatorid(String operatorid) {
        this.operatorid = operatorid == null ? null : operatorid.trim();
    }

    public String getOperatorname() {
        return operatorname;
    }

    public void setOperatorname(String operatorname) {
        this.operatorname = operatorname == null ? null : operatorname.trim();
    }

    public Integer getEntityavailablestate() {
        return entityavailablestate;
    }

    public void setEntityavailablestate(Integer entityavailablestate) {
        this.entityavailablestate = entityavailablestate;
    }

    public void initInfo(){
        this.setCreatedtime(new Date());
        this.setChangedtime(new Date());
        this.setEntityavailablestate(10);
    }

    @JsonFormat(pattern = "yyyy-MM-dd")
    public Date getCreatedtimeYMD() {
        return createdtimeYMD;
    }

    public void setCreatedtimeYMD(Date createdtimeYMD) {
        this.createdtimeYMD = createdtimeYMD;
    }

    @JsonFormat(pattern = "yyyy-MM-dd")
    public Date getChangedtimeYMD() {
        return changedtimeYMD;
    }

    public void setChangedtimeYMD(Date changedtimeYMD) {
        this.changedtimeYMD = changedtimeYMD;
    }
}
